// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <tests/exec/DummyAggregateFunction.h>

namespace kumo::pollux::exec::test {

AggregateRegistrationResult registerDummyAggregateFunction(
    const std::string& name,
    const std::vector<AggregateFunctionSignaturePtr>& signatures,
    bool overwrite) {
  return registerAggregateFunction(
      name,
      signatures,
      [&](core::AggregationNode::Step step,
          const std::vector<TypePtr>& argTypes,
          const TypePtr& resultType,
          const core::QueryConfig& /*config*/)
          -> std::unique_ptr<exec::Aggregate> {
        POLLUX_CHECK_GE(argTypes.size(), 1);
        if (isPartialOutput(step)) {
          return std::make_unique<DummyDicitonaryFunction>(argTypes[0]);
        }
        return std::make_unique<DummyDicitonaryFunction>(resultType);
      },
      /*registerCompanionFunctions*/ true,
      overwrite);
}

} // namespace kumo::pollux::exec::test
